package com.libowu.guide.activity;

import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.libowu.guide.R;
import com.libowu.guide.bean.GuideBean;
import com.libowu.guide.dialog.GuideDialog;
import com.libowu.guide.view.GuideView;

import java.util.ArrayList;
import java.util.List;

public class CustomFragment extends Fragment {
    private TextView test,test_two,test_three;
    private List<GuideBean> guides;
    private String age;
    private GuideDialog guideDialog;
    private View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Log.e("日志","1");
        return inflater.inflate(R.layout.activity_main,container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        this.view = view;
        Log.e("日志","2");

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.e("日志","3");
        FindViewUtils.getInstance().bindView(getActivity(),null);
        test = getActivity().findViewById(R.id.test);
        test_two = getActivity().findViewById(R.id.test_two);
        test_three = getActivity().findViewById(R.id.test_three);

        //将要说明的控件添加到集合中，让后给guideview设置数据即可
        guides = new ArrayList<>();
        guides.add(new GuideBean(R.mipmap.guide,new Rect(0,0,400,400),getActivity(),null, 0,0));
        guides.add(new GuideBean(R.mipmap.guide,getActivity(),test));
        guides.add(new GuideBean(R.mipmap.guide,getActivity(),test_two));
        guides.add(new GuideBean(R.mipmap.guide,getActivity(),test_three));
        //int img,Rect rect,Activity act,String text,int position,int textAlign

        guideDialog = new GuideDialog(view);
        guideDialog.setGuideBeans(guides);
        guideDialog.show(getFragmentManager(),getClass().getName());
    }
}
